public class thread {
    public static void main(String[] args) {
        a at = new a();
        b bt = new b();
        at.start();
        bt.start();

    }


}
class a extends Thread{
    public void run() {
        System.out.println("A启动");
        try {
            b bt = new b();
            bt.start();
            bt.join();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("A结束");
    }
}
class b extends Thread{
    public void run() {
        System.out.println("b启动");
        try {
            a at = new a();
            at.start();
            at.join();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("b结束");
    }
}